const deepClone = require("../template.js")

/** 0. 基本类型测试 */
function testBasic() {
  console.log(
    "0.1 基本类型:",
    deepClone(1) === 1 &&
      deepClone("hello") === "hello" &&
      deepClone(true) === true &&
      deepClone(null) === null &&
      deepClone(undefined) === undefined
  )

  // this上下文测试
  const cloneObj = {
    prefix: "cloned_",
    processClone: function(obj) {
      const cloned = deepClone(obj)
      if (typeof cloned === 'string') {
        return this.prefix + cloned
      }
      return cloned
    }
  }
  console.log("0.2 this上下文测试:", cloneObj.processClone("test") === "cloned_test")

  // 复杂对象this绑定测试
  const cloneConfigObj = {
    config: { suffix: "_processed" },
    processWithConfig: function(obj) {
      const cloned = deepClone(obj)
      if (typeof cloned === 'string') {
        return cloned + this.config.suffix
      }
      return cloned
    }
  }
  console.log("0.3 复杂对象this绑定测试:", cloneConfigObj.processWithConfig("hello") === "hello_processed")

  console.log("--------------------")
}

testBasic()

module.exports = testBasic
